#include <iostream>
#include <vector>

using namespace std;

//递归流程
void findArround(int i, int j, int &area, vector<vector<int>> &grid)
{
    int r = grid.size();
    int c = grid[0].size();
    //左
    if (j - 1 >= 0 && grid[i][j - 1])
    {
        area++;
        grid[i][j - 1] = 0;
        findArround(i, j - 1, area, grid);
    }

    //右
    if (j + 1 < c && grid[i][j + 1])
    {
        area++;
        grid[i][j + 1] = 0;
        findArround(i, j + 1, area, grid);
    }

    //上
    if (i - 1 >= 0 && grid[i - 1][j])
    {
        area++;
        grid[i - 1][j] = 0;
        findArround(i - 1, j - 1, area, grid);
    }

    //下
    if (i + 1 < r && grid[i + 1][j])
    {
        area++;
        grid[i + 1][j] = 0;
        findArround(i + 1, j, area, grid);
    }
}

int maxAreaOfIsland(vector<vector<int>> &grid)
{
    int maxarea = 0;
    int r = grid.size();    //row
    int c = grid[0].size(); //column
    int area = 0;

    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            if (grid[i][j])
            {
                grid[i][j] = 0;
                area++;
                findArround(i, j, area, grid);
            }
            maxarea = (maxarea > area) ? maxarea : area;
            area = 0;
        }
    }

    return maxarea;
}

int main()
{
    int r, c;
    cin >> r;
    cin >> c;

    vector<vector<int>> grid(r, vector<int>(c));
    for (int i = 0; i < r; i++)
        for (int j = 0; j < c; j++)
            cin >> grid[i][j];

    int maxarea = maxAreaOfIsland(grid);
    cout << maxarea << endl;
    return 0;
}



#if 0
#include <iostream>
#include <vector>

using namespace std;

//递归流程
void findArround(int i, int j, int &area, int arr[3][3])
{
    //左
    if (j - 1 >= 0 && arr[i][j - 1])
    {
        area++;
        arr[i][j - 1] = 0;
        findArround(i, j - 1, area, arr);
    }

    //右
    if (j + 1 < 3 && arr[i][j + 1])
    {
        area++;
        arr[i][j + 1] = 0;
        findArround(i, j + 1, area, arr);
    }

    //上
    if (i - 1 >= 0 && arr[i - 1][j])
    {
        area++;
        arr[i - 1][j] = 0;
        findArround(i - 1, j - 1, area, arr);
    }

    //下
    if (i + 1 < 3 && arr[i + 1][j])
    {
        area++;
        arr[i + 1][j] = 0;
        findArround(i + 1, j, area, arr);
    }
}


int maxAreaOfIsland(int arr[3][3])
{
    int maxarea = 0;
    int r = 3;  //row
    int c = 3; //column
    int area = 0;

    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            if (arr[i][j])
            {
                arr[i][j] = 0;
                area++;
                findArround(i, j, area, arr);
            }
            maxarea = (maxarea > area) ? maxarea : area;
            area = 0;
        }
    }

    return maxarea;
}

int main()
{
    int arr[3][3] =
    {0,0,1,
    1,0,1,
    1,1,1
    };
        // {0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
        //  0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0,
        //  0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
        //  0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0,
        //  0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0,
        //  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
        //  0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0,
        //  0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0};

    int maxarea = maxAreaOfIsland(arr);
    cout << maxarea << endl;
    return 0;
}
#endif